"""
File: exapmle_1_1_1_1.py
Project: 活动1_设计创意书签
File Created: 2020/02/10 11:11:18
Author: Dunmore (fovd2020@outlook.com)
----------------------------------------
Description:设计创意书签(1.1.1 活动1)
1. 读取八年级下英语教材目录.txt
2. 用wordcloud输出
----------------------------------------
"""
import os
from wordcloud import WordCloud

currrent_dir = (
    os.path.dirname(__file__) if "__file__" in locals() else os.getcwd()
)
# 读取八年级英语教材目录
text = open(
    os.path.join(currrent_dir, "八年级下英语教材目录.txt"), "r", encoding="UTF-8"
).read()

# 生成词云对象
wordcloud = WordCloud().generate(text)

# 生成图片并显示,需要安装Pillow
image = wordcloud.to_image()
image.show()
